package com.shr.code_interview;

import java.util.ArrayList;

public class Solution_57 {
    public ArrayList<Integer> FindNumbersWithSum(int [] array,int sum) {
        int low = 0, up = array.length - 1;
        while(low < up){
        	if(array[low] + array[up] == sum)
        		break ;
        	else if(array[low] + array[up] > sum)
        		up--;
        	else low++;
        }
        ArrayList<Integer> list = new ArrayList<>();
        if(low < up && array[low] + array[up] == sum){
	        list.add(array[low]);
	        list.add(array[up]);
        }
        return list;
    }	
}
